package 数组.练习;

public class 练习6 {

    //定义一个方法判断两个数组是否一致（长度、元素的值）
    public static void main(String[] args) {
            int arr1[]={1,2,3};
            int arr2[]={1,2,4};
        System.out.println(same(arr1,arr2));
    }

    public static boolean  same(int arr1[],int arr2[]){
        //1.先判断长是否一致
        if(arr1.length!=arr2.length){
            return false;
        }
        //2.判断元素是否一致
        for (int i = 0; i < arr1.length; i++) {
            if(arr1[i]!=arr2[i]){//一致
                return false;
            }
        }
        return true;
    }
}
